package pkg

import (
	"encoding/json"
	"github.com/Baidu-AIP/golang-sdk/aip/censor"
)

func Text(str string) bool {
	client := censor.NewClient("FxoFtiGYEyNvSrBf9iRySA4v", "Ct6G4De7rywFd3FXBtMzjz2ntdJpjXSI")
	res := client.TextCensor(str)
	var text Texts
	json.Unmarshal([]byte(res), &text)
	if text.ConclusionType == 1 {
		return true
	}
	return false
}

type Texts struct {
	LogId          int    `json:"log_id"`
	ErrorCode      int    `json:"error_code"`
	ErrorMsg       string `json:"error_msg"`
	Conclusion     string `json:"conclusion"`
	ConclusionType uint64 `json:"conclusionType"`
}
